/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: DynamicDataSource
 * Author:   wh
 * Date:     2019/4/30 12:09
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package io.imp.dynamic.datasource.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @program: imp-security
 * @ClassName: DynamicDataSource
 * @Description:
 * @author: wanghui
 * @date: 2019/4/30 12:09
 * @Version: 1.0.0
 */
@Slf4j
public class DynamicDataSource extends AbstractRoutingDataSource {

    /**
     * 指定路由Key,这里很简单 获取 threadLocal 中目标key 即可
     *
     * @return
     */
    @Override
    protected Object determineCurrentLookupKey() {
        return DynamicContextHolder.peek();
    }


}
